package com.training1.core.modules.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.training1.core.common.entity.UserEntity;
import com.training1.core.common.service.CrudService;
import com.training1.core.entity.SystemUserEntity;
import com.training1.core.modules.dao.SystemUserDao;

/**
 * 后台用户管理service
 * @author Administrator
 *
 */
@Service
@Transactional
public class SystemUserService extends CrudService<SystemUserDao, SystemUserEntity>{
	
	/**
	 * 判断用户名是否存在
	 * @param user
	 * @return 
	 */
	public boolean isUserExist(SystemUserEntity systemUser){
		return dao.isUserExist(systemUser) != null;
	}
	
	/**
	 * 获得所有user_name
	 * @param user
	 * @return 
	 */
	public List<UserEntity> findAllUserName(){
		Map<String, Object> param =  new HashMap<String, Object>();
		param.put("userRole", 1);
		return dao.findAllUserName(param);
	}
	/**
	 * union连接
	 * @param user
	 * @return 
	 */
	public List<SystemUserEntity> union(){
		return dao.union();
	}
	/**
	 *unionAll连接
	 * @param user
	 * @return 
	 */
	public List<SystemUserEntity> unionAll(){
		return dao.unionAll();
	}
	/**
	 *逗号实现交叉连接
	 * @param user
	 * @return 
	 */
//	public List<SystemUserEntity> crossjoin(){
//		return dao.crossjoin();
//	}
	/**
	 *子查询
	 * @param user
	 * @return 
	 */
	public List<SystemUserEntity> ziSearch(){
		return dao.ziSearch();
	}
}
